package com.xcl.service.impl;

import com.xcl.mapper.FinancingMapper;
import com.xcl.mapper.OutsourcingCostMapper;
import com.xcl.pojo.OutsourcingCost;
import com.xcl.service.OutsourcingCostServiceInter;
import com.zzg.entity.Finance;
import com.zzg.entity.Outsourcing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName OutsourcingCostServiceImpl
 * @Description 外包费用
 * @Author: xiaochaolei
 * @date 2021/7/23 16:27
 * @Version 1. 0
 */
@Service
public class OutsourcingCostServiceImpl implements OutsourcingCostServiceInter {
    @Autowired
    OutsourcingCostMapper outsourcingCostMapper;
    @Autowired
    FinancingMapper financingMapper;

    @Override
    public List<OutsourcingCost> getAllOutsourcingCost() {
        return outsourcingCostMapper.getAllOutsourcingCost();
    }

    @Override
    public List<OutsourcingCost> getAllOutsourcingCostByLimit(int page, int limit,String outsourcingOrder,String  waybill_id,String eeforwardingUnit,String forwardingUnit
            ,String date,String type,String loname,String city) {
        return outsourcingCostMapper.getAllOutsourcingCostByLimit((page-1)*limit,limit,outsourcingOrder,waybill_id,eeforwardingUnit,forwardingUnit,date,type,loname,city);
    }

    @Override
    public Outsourcing getOutsourcingByOutsourcingorder(String outsourcingorder) {
        return outsourcingCostMapper.getOutsourcingByOutsourcingorder(outsourcingorder);
    }

    @Override
    public int updateCostBreakdown(Outsourcing outsourcing) {
        //根据外包单号查询财务信息
        Finance financeOutsourcingId = outsourcingCostMapper.getFinanceOutsourcingId(outsourcing.getOutsourcingId());

        //设置财务状态
        financeOutsourcingId.setOrdertype("已结清");
        //修改财务信息
        financingMapper.updateFinancing(financeOutsourcingId);
        //修改核销状态
        financingMapper.updateVerification(financeOutsourcingId.getOrdernumber());
        //修改财务详细信息
        return  outsourcingCostMapper.updateCostBreakdown(financeOutsourcingId.getCostbreakdownId());
    }
}
